using System;
using System.Security;

namespace SolutionFactory.Exporter
{
    public class VSContent
    {
        public static string Create(string filename, string templateName, string description, string type,
                                    string subtype)
        {
            return string.Format(
                @"<?xml version=""1.0"" encoding=""utf-8""?>
<VSContent 
    xmlns=""http://schemas.microsoft.com/developer/vscontent/2005"">
  <Content>
    <FileName>{0}</FileName>
    <DisplayName>{1}</DisplayName>
    <Description>{2}</Description>
    <FileContentType>VSTemplate</FileContentType>
    <ContentVersion>2.0</ContentVersion>
    <Attributes>
      <Attribute name=""TemplateType"" value=""Project""></Attribute>
      <Attribute name=""ProjectType"" value=""{3}""></Attribute>
      <Attribute name=""ProjectSubType"" value=""{4}""></Attribute>
    </Attributes>
  </Content>
</VSContent>",
                Encode(filename), Encode(templateName), Encode(description), Encode(type.Replace("CSharp", "Visual C#")), Encode(subtype));
        }

        private static string Encode(string input)
        {
            return SecurityElement.Escape(input);
        }
    }
}